import 'dart:convert';

import 'package:flutter/widgets.dart';
import 'package:x3_base_core/base_models/base_key_value_model.dart';
import 'package:x3_base_core/base_models/base_model_asT.dart';

/// 下方弹出选择器 model
class BaseBottomSheetSelectorModel extends BaseKeyValueModel {
  /// 值
  final dynamic key;

  /// 名称
  final String value;

  BaseBottomSheetSelectorModel({@required this.key, @required this.value}) : super(key: key, value: value);

  factory BaseBottomSheetSelectorModel.fromJson(Map<String, dynamic> jsonRes) => jsonRes == null ? null : BaseBottomSheetSelectorModel(key: asT<dynamic>(jsonRes['key']), value: asT<String>(jsonRes['value']));

  Map<String, dynamic> toJson() => <String, dynamic>{'key': key, 'value': value};
  @override
  String toString() {
    return json.encode(this);
  }

  static List<BaseBottomSheetSelectorModel> getListBaseSelectDownItem(List<Map> list) {
    return list.map((e) => BaseBottomSheetSelectorModel(key: e['key'], value: e['value'])).toList();
  }
}
